//http://h5.eqxiu.com/s/DmvIln0A

import fetch from 'node-fetch';
import { CollectInfo } from "../interfaces";

async function analysis(url: string): Promise<CollectInfo> {
    let html = await fetch(url).then(_ => _.text())

    let [, id, code, title] = html.match(/id:(\d+)[^]*?code:"(\w+)"[^]*?name: "(.+?)"/m)

    return Promise.resolve({
        url: `http://s1.eqxiu.com/eqs/page/${id}?code=${code}`
        , title
        , id
        , origin: url
    })
}

export default analysis